﻿using System;
using System.Data;
using Gencode.Common.SQL;

namespace Gencode.PrsCommon.App.AppData
{
    public class DataGenerator
    {
		///// <summary>
		///// Creates a DataView with Dienste. Set dienstID = 0 for all Dienste. Anzeigename,DienstID,Name,Kuzrtext,RGB
		///// </summary>
		///// <returns>Anzeigename,DienstID,Name,Kuzrtext,RGB</returns>
		//public static DataView GetDienste(string mandid, int dienstID)
		//{
		//    Querry querry = new Querry();
		//    querry.SetSTPName("get_dienstlisting");
		//    querry.AddParameter("@mandid", mandid);
		//    querry.AddParameter("@dienstid", dienstID);

		//    return querry.ExecuteForDataView();
		//}

		///// <summary>
		///// Creates a DataView with all Dienste. Anzeigename,DienstID,Name,Kuzrtext,RGB
		///// </summary>
		///// <returns>Anzeigename,DienstID,Name,Kuzrtext,RGB</returns>
		//public static DataView GetDienste(string mandid)
		//{
		//    return GetDienste(mandid, 0);
		//}

		///// <summary>
		///// Creates a DataView with all Dienste. Anzeigename,DienstID,Name,Kuzrtext,RGB
		///// </summary>
		///// <param name="mandid">Mandant</param>
		///// <param name="addemptyrow">Add empty row at top?</param>
		///// <returns>Anzeigename,DienstID,Name,Kuzrtext,RGB</returns>
		//public static DataView GetDienste(string mandid, bool addemptyrow)
		//{
		//    DataView dv = GetDienste(mandid, 0);

		//    if (addemptyrow)
		//    {
		//        //create empty row
		//        DataRow row = dv.Table.NewRow();
		//        row[0] = ""; //Anzeigename
		//        row[1] = "0"; //DienstID
		//        row[2] = ""; //Name
		//        row[3] = ""; //Kurztext
		//        row[4] = "0"; //RGB

		//        dv.Table.Rows.InsertAt(row, 0);
		//    }

		//    return dv;
		//}




		//[System.Obsolete("Use Namespace Gencode.PrsCommon.Data.Common",false)]
		//public static string GetMandant(string user)
		//{
		//    DataView dv = SimpleQuerry.ExecuteForDataView("select mandid from userrights where loginname = '" + user + "'");
		//    return dv[0].Row[0].ToString();
		//}

        public static DataView GetFeiertageProPlan(int planID)
        {
			DataView dv = SimpleQuerry.ExecuteForDataView("select Von,Bis,JahrID from ArbeitsPlan where PlanID = " + planID);
			string ex = "select Von from ArbeitsTage where typwert = 2 and Von between '" + dv[0].Row[0].ToString() + "' and '" + dv[0].Row[1].ToString() + "' and JahrID = " + dv[0].Row[2].ToString();
            return SimpleQuerry.ExecuteForDataView(ex);
        }

		///// <summary>
		///// Creates a list of every person in a plan. 
		///// prsID,name,nachname,abteilungid,abteilungname,prsschemaid,von,bis,rgb
		///// </summary>
		///// <param name="planID">PlanID Attribut</param>
		///// <returns>prsID,name,nachname,abteilungid,abteilungname,prsschemaid,von,bis,rgb</returns>
		//public static DataView GetPersonenInPlan(int planID)
		//{
		//    Querry query = new Querry();
		//    query.SetSTPName("get_personeninplan");
		//    query.AddParameter("@planid", planID);

		//    return query.ExecuteForDataView();
		//}

		//public static DataView GetPlanRow(int planID, int prsSchemaID, int prsid)
		//{
		//    Querry query = new Querry();
		//    query.SetSTPName("get_planrow");
		//    query.AddParameter("@panid", planID);
		//    query.AddParameter("@prsschemaid", prsSchemaID);
		//    query.AddParameter("@prsid", prsid);
		//    return query.ExecuteForDataView();
		//}

		//public static DataView GetPlanRowColors(int planID, int prsSchemaID)
		//{
		//    Querry query = new Querry();
		//    query.SetSTPName("get_planrowcolor");
		//    query.AddParameter("@planid", planID);
		//    query.AddParameter("@prsschemaid", prsSchemaID);
		//    return query.ExecuteForDataView();
		//}

		///// <summary>
		///// Creates a DataView with Months of active Year. JahrID,Jahr,Name,von,bis,ATID,Tage
		///// </summary>
		///// <returns>JahrID,Jahr,Name,von,bis,ATID,Tage</returns>
		//public static DataView GetActiveMonths(string mandid)
		//{
		//    Querry querry = new Querry();
		//    querry.SetSTPName("get_activemonths");
		//    querry.AddParameter("@mandid", mandid);

		//    return querry.ExecuteForDataView();
		//}

		///// <summary>
		///// Creates a DataView with Schemas. [schemaid,name]
		///// </summary>
		///// <param name="mandid">mandid</param>
		///// <param name="onlyActive">get only active?</param>
		///// <returns>schemaid,name</returns>
		//public static DataView GetSchemas(string mandid, bool onlyActive)
		//{
		//    int status = 1;
		//    if (!onlyActive)
		//        status = 0;

		//    Querry query = new Querry();
		//    query.SetSTPName("get_shemas");
		//    query.AddParameter("@mandid", mandid);
		//    query.AddParameter("@status", status);
		//    return query.ExecuteForDataView();
		//}

		///// <summary>
		///// vortrag,soll,haben,ferien
		///// </summary>
		///// <param name="prsid"></param>
		///// <param name="abteilungid"></param>
		///// <param name="planid"></param>
		///// <returns></returns>
		//[System.Obsolete("Use Namespace Gencode.PrsCommon.Data.Plan",false)]
		//public static DataView GetSaldo(int prsid, int abteilungid, int planid)
		//{
		//    Querry query = new Querry();
		//    query.SetSTPName("get_saldo");
		//    query.AddParameter("@prsid", prsid);
		//    query.AddParameter("@planid", planid);
		//    query.AddParameter("@abteilungid", abteilungid);

		//    return query.ExecuteForDataView();
		//}
    }
}
